home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.cyberramp.net!news
- From: sinan@cyberramp.net (John L. Hollander)
- Newsgroups: comp.lang.c
- Subject: Re: Windows DLL
- Date: 11 Apr 1996 22:45:24 GMT
- Organization: Uno mas por favor
- Message-ID: <4kk224$4ns@newshost.cyberramp.net>
- References: <4kgqcg$g4p@reader2.ix.netcom.com>
- NNTP-Posting-Host: ramp1-29.cyberramp.net
- X-Newsreader: WinVN 0.99.5
-
- In article <4kgqcg$g4p@reader2.ix.netcom.com>, bmwells@ix.netcom.com says...
- >
- >I can't use sscanf in my MS1.51 Visual C++ compiler when making a DLL.
- >What confuses me is the fact that strings can be used in DLLs. So what
- >functions do I use to break strings down and manipulate them within
- >a DLL??
- >
-
- This is a platform dependent question, so here is the platform dependent
- answer:
- In a DLL, DS != SS, since the DLL has its own heap, but uses the
- callers stack. Therefore functions that take shortcuts and count on
- DS == SS, don't work in a DLL. With some compilers, all of the C
- functions that take a variable number of parameters, like sscanf(),
- use a macro that assumes DS == SS. The Windows function wsprintf()
- takes a variable number of arguments, but can be used in a DLL. It was
- written as a Windows function from the ground up and doesn't make
- these assumptions.
-
- Your options are:
- - Rewrite the varargs.h or stdarg.h macros to accomodate use in DLL.
- - Do without the standard functions and write your own routines.
- - Find suitable Windows replacements and use them instead.
-
- Many people have run up against this same issue, I'm sure you would
- get better responses by posting to the comp.os.ms-windows.programmer
- groups. If you look around the net a little, I bet you could find
- Windows replacements for all of these functions. You might also look
- for a book on writing DLLs since there are other similar issues that
- will bite you in the ass. If DS != SS, where are automatic variables
- stored? If you have a pointer to one you'll probably find out. What
- happens when you try and access an automatic array(or string)? [THINK
- FAR!] If you declare all your variables static, what happens when more
- than one program calls your function? A DLL has its own heap, but it
- only has one, no matter how many different programs call it. Is your
- function prepared to be reentrant?
-
- -John
-
-